/*
* File:			queue.h
* Author:		Akira
* Date:			2023-11-15
* Description:	队列的链式存储实现
* Version: 		1.0.0
* Modify: 		None.
*/

#ifndef __QUEUE_H__
#define __QUEUE_H__

#include <stdlib.h>
#include <stdbool.h>
#include <malloc.h>

//1：带头节点；0：不带头节点
#define QUEUE_WITH_HEAD_NODE 	1

//队列的链式存储实现（带头节点和不带头节点）

typedef int ElemType;
typedef struct LinkNode {
	ElemType data;
	struct LinkNode* next;
} LinkNode;

typedef struct {
	LinkNode* front;  			//头指针指向头节点
	LinkNode* rear;	  			//尾指针指向尾节点
	int length;					//队列长度
} LinkQueue;

extern void InitQueue(LinkQueue* q);
extern bool IsEmpty(LinkQueue* q);
extern bool EnQueue(LinkQueue* q, ElemType x);
extern bool DeQueue(LinkQueue* q, ElemType* x);
extern int LengthQueue(LinkQueue* q);
extern bool GetLead(LinkQueue *q, ElemType *x);

#endif /* __QUEUE_H__ */
